import { Route,Switch,Redirect } from 'react-router-dom'
import {withRouter} from 'react-router-dom'
import {useEffect,useState} from 'react'
import NavHeader from '../../components/NavHeader'
import NavFooter from '../../components/NavFooter'
import Member from './Member'
import BlogDetail from '../BlogDetail/index.jsx'
import Home from '../Home'
import Login from '../Login'
import WriteCenter from '../WriteCenter'
import './index.less'

function Container(props){

  const [pathName,setPathName] = useState('')

  useEffect(()=>{
    setPathName(props.location.pathname)
  },[])// eslint-disable-line

  return (
    <div className='baseContainer flex column'>
      {pathName!=='/writeCenter'?<NavHeader />:''}
      <Switch>
      
        {/* <h2>我是容器组件</h2> */}
        
        <Route exact component={Member} path="/member"></Route>
        <Route component={Home} path="/home"></Route>
        <Route exact component={Login} path="/login"></Route>
        <Route exact component={WriteCenter} path="/writeCenter"></Route>
        <Route exact component={BlogDetail} path="/blogDetail"></Route>
        <Redirect to="/member" />
      </Switch>
      <NavFooter />
    </div>
  )
}

export default withRouter(Container)